<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>


<f:subview id="customers">
	<a4j:loadBundle var="msg" basename="messages_#{localManager.local}"></a4j:loadBundle>
	<h:form style="overflow:auto">
		<script type="text/javascript">
			var row;
		</script>
		<a4j:region>
			<rich:dataTable value="#{customersManager.dataList}" var="dataItem"
				reRender="ds" id="customersList"
				onRowContextMenu="row=this; alert(this);"
				onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
				onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
				cellpadding="0" cellspacing="0" border="0" rows="20">

				<f:facet name="header">
					<h:outputText value="#{msg['kurier.klienci.klienci']}" />
				</f:facet>

				<rich:column width="25" sortBy="#{dataItem.idKlienta}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.klienci.id']}" />
					</f:facet>
					<h:outputText value="#{dataItem.idKlienta}" />
				</rich:column>

				<rich:column width="25" sortBy="#{dataItem.idUzytk}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.klienci.idUzytk']}" />
					</f:facet>
					<h:outputText value="#{dataItem.idUzytk}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.imie}}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.zlec.tab.imie']}" />
					</f:facet>
					<h:outputText value="#{dataItem.imie}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.nazwisko}" filterBy="#{dataItem.nazwisko}" filterEvent="onkeyup">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.zlec.tab.nazwisko']}" />
					</f:facet>
					<h:outputText value="#{dataItem.nazwisko}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.adres}" filterBy="#{dataItem.nazwisko}" filterEvent="onkeyup">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.zlec.tab.adres']}" />
					</f:facet>
					<h:outputText id="imieOutput" value="#{dataItem.adres}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.miasto}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.zlec.tab.miasto']}" />
					</f:facet>
					<h:outputText value="#{dataItem.miasto}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.kod}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.zlec.tab.kod']}" />
					</f:facet>
					<h:outputText value="#{dataItem.kod}" />
				</rich:column>



				<rich:column>
					<a4j:commandLink ajaxSingle="true" id="editlink"
						action="#{customersManager.prepareEditData}"
						oncomplete="#{rich:component('editMPcustomers')}.show()">
						<h:graphicImage value="/images/edit.gif" style="border:0" />
						<f:setPropertyActionListener value="#{dataItem}"
							target="#{customersManager.editedData}" />
						
					</a4j:commandLink>
					<rich:toolTip for="editlink" value="#{msg['kurier.zlec.edit']}" />

					<a4j:commandLink ajaxSingle="true" id="deleteLink"
						oncomplete="#{rich:component('deleteMPcustomers')}.show()">
						<h:graphicImage value="/images/delete.gif" style="border:0" />
						<f:setPropertyActionListener value="#{dataItem}"
							target="#{customersManager.editedData}" />
					
					</a4j:commandLink>
					<rich:toolTip for="deleteLink" value="#{msg['kurier.zlec.usun']}" />
				</rich:column>

				<f:facet name="footer">
					<rich:datascroller id="ds" align="center" for="customersList"
						 maxPages="20" />
				</f:facet>
			</rich:dataTable>
			<a4j:commandButton styleClass="RFbutton"
				value="#{msg['kurier.zlec.dodaj']}"
				action="#{customersManager.prepareAddData}" reRender="customersList"
				oncomplete="#{rich:component('addMPcustomers')}.show()">
			</a4j:commandButton>
			<a4j:commandButton styleClass="RFbutton"
				value="#{msg['kurier.zlec.odswierz']}"
				action="#{customersManager.refreshData}" reRender=" customersList">
			</a4j:commandButton>
	 <rich:messages id="mymessages"  globalOnly="true"  style="color:red"/>
		</a4j:region>
	</h:form>


	<rich:modalPanel id="editMPcustomers" domElementAttachment="parent"
		autosized="true" width="350" height="350">
		<f:facet name="header">
			<h:outputText id="editLabel" value="#{msg['kurier.zlec.edit']}"></h:outputText>
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/close2.png" styleClass="hidelink"
					id="hidelink" />
				<rich:componentControl for="editMPcustomers" attachTo="hidelink"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<a4j:outputPanel ajaxRendered="true">
				<h:panelGrid columns="3" border="0">

					<h:column>
						<h:outputLabel for="imie" value="#{msg['kurier.zlec.tab.imie']}:" />
					</h:column>
					<h:column>
						<h:inputText id="imie" value="#{customersManager.editedData.imie}"
							immediate="true" required="true" maxlength="70" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="imie" />
					</h:column>

					<h:column>
						<h:outputLabel for="nazwisko"
							value="#{msg['kurier.zlec.tab.nazwisko']}:" />
					</h:column>
					<h:column>
						<h:inputText id="nazwisko"
							value="#{customersManager.editedData.nazwisko}" immediate="true"
							required="true" maxlength="120" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="nazwisko" />
					</h:column>

					<h:column>
						<h:outputLabel for="adres"
							value="#{msg['kurier.zlec.tab.adres']}:" />
					</h:column>
					<h:column>
						<h:inputText id="adres"
							value="#{customersManager.editedData.adres}" immediate="true"
							required="true" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="adres" />
					</h:column>

					<h:column>
						<h:outputLabel for="adres"
							value="#{msg['kurier.zlec.tab.miasto']}:" />
					</h:column>
					<h:column>
						<h:inputText id="miasto"
							value="#{customersManager.editedData.miasto}" immediate="true"
							required="true" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="miasto" />
					</h:column>

					<h:column>
						<h:outputLabel for="kod" value="#{msg['kurier.zlec.tab.kod']}:" />
					</h:column>
					<h:column>
						<h:inputText id="kod" value="#{customersManager.editedData.kod}"
							immediate="true" required="true" />
					</h:column>
					<h:column>
							
					</h:column>

					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.zapisz']}"
						action="#{customersManager.editData}"
						reRender=" customersList"
						oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editMPcustomers')}.hide();}">
					</a4j:commandButton>
					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.anuluj']}"
						onclick="#{rich:component('editMPcustomers')}.hide(); return false;" />

				</h:panelGrid>
				 <rich:messages id="mymessages"  globalOnly="true"  style="color:red"/>
			</a4j:outputPanel>
			
		</h:form>

	</rich:modalPanel>

	<rich:modalPanel id="addMPcustomers" domElementAttachment="parent"
		autosized="true" width="300" height="300">
		<f:facet name="header">
			<h:outputText id="addLabel" value="#{msg['kurier.zlec.dodaj']}"></h:outputText>
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/close2.png" styleClass="hidelink"
					id="addhidelink" />
				<rich:componentControl for="addMPcustomers" attachTo="addhidelink"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>


		<h:form>
			<a4j:outputPanel ajaxRendered="true">
				<h:panelGrid columns="3" border="0">

					<h:column>
						<h:outputLabel for="addid"
							value="#{msg['kurier.klienci.idUzytk']}:" />
					</h:column>
					<h:column>

						<h:selectOneMenu id="addid"
							value="#{customersManager.editedData.idUzytk}">
							<f:selectItems value="#{customersManager.uzytkownicyList}" />
						</h:selectOneMenu>
					</h:column>
					<h:column>
						<h:message style="color:red" for="addid" />
					</h:column>

					<h:column>
						<h:outputLabel for="addimie"
							value="#{msg['kurier.zlec.tab.imie']}:" />
					</h:column>
					<h:column>
						<h:inputText id="addimie"
							value="#{customersManager.editedData.imie}" immediate="true"
							required="true" maxlength="70" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="addimie" />
					</h:column>

					<h:column>
						<h:outputLabel for="addnazwisko"
							value="#{msg['kurier.zlec.tab.nazwisko']}:" />
					</h:column>
					<h:column>
						<h:inputText id="addnazwisko"
							value="#{customersManager.editedData.nazwisko}" immediate="true"
							required="true" maxlength="120" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="addnazwisko" />
					</h:column>

					<h:column>
						<h:outputLabel for="addadres"
							value="#{msg['kurier.zlec.tab.adres']}:" />
					</h:column>
					<h:column>
						<h:inputText id="addadres"
							value="#{customersManager.editedData.adres}" immediate="true"
							required="true" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="addadres" />
					</h:column>

					<h:column>
						<h:outputLabel for="addadres"
							value="#{msg['kurier.zlec.tab.miasto']}:" />
					</h:column>
					<h:column>
						<h:inputText id="addmiasto"
							value="#{customersManager.editedData.miasto}" immediate="true"
							required="true" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="addmiasto" />
					</h:column>

					<h:column>
						<h:outputLabel for="addkod" value="#{msg['kurier.zlec.tab.kod']}:" />
					</h:column>
					<h:column>
						<h:inputText id="addkod"
							value="#{customersManager.editedData.kod}" immediate="true"
							required="true" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="addkod" />
					</h:column>


					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.zapisz']}"
						action="#{customersManager.addData}" reRender="customersList" 
						oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('addMPcustomers')}.hide();}"/>
					<a4j:commandButton styleClass="RFbutton" value="Cancel"
						onclick="#{rich:component('addMPcustomers')}.hide(); return false;" />

				</h:panelGrid>
				 <rich:messages id="mymessages"  globalOnly="true"  style="color:red"/>
			</a4j:outputPanel>
		</h:form>
	</rich:modalPanel>

	<rich:modalPanel id="deleteMPcustomers" autosized="true" width="200">
		<f:facet name="header">
			<h:outputText value="#{msg['kurier.zlec.usun']}"
				style="padding-right:15px;" />
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/close2.png" styleClass="hidelink"
					id="hidelink2" />
				<rich:componentControl for="deleteMPcustomers" attachTo="hidelink2"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
		<a4j:outputPanel>
			<table width="100%">
				<tbody>
					<tr>
						<td align="center" width="50%"><a4j:commandButton
								styleClass="RFbutton" value="#{msg['kurier.zlec.tak']}"
								ajaxSingle="true"
								action="#{customersManager.deleteData}"
								oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('deleteMPcustomers')}.hide();}"
								reRender="customersList" /></td>
						<td align="center" width="50%"><a4j:commandButton
								styleClass="RFbutton" value="#{msg['kurier.zlec.nie']}"
								onclick="#{rich:component('deleteMPcustomers')}.hide();return false;" />
						</td>
					</tr>
				</tbody>
			</table>
			
			
			<rich:messages id="mymessages" globalOnly="true" style="color:red" />
			</a4j:outputPanel>
		</h:form>
	</rich:modalPanel>
	<a4j:status onstart="#{rich:component('wait')}.show()"
		onstop="#{rich:component('wait')}.hide()" />
	<rich:modalPanel id="wait" autosized="true" width="200" height="120"
		moveable="false" resizeable="false">
		<f:facet name="header">
			<h:outputText value="Processing" />
		</f:facet>
		<h:outputText value="Wait Please..." />
	</rich:modalPanel>


<rich:modalPanel id="deleteMPcustomers1" showWhenRendered="#{facesContext.maximumSeverity != null}">
   <!-- every severity has a ordinal number, im not sure but 0 = info, 1 = warn, 2 = error and 3 = fatal, i guess -->
   <h:panelGrid columns="2" rendered="#{facesContext.maximumSeverity.ordinal == 0}">
      <h:graphicImage value="/images/icons/mini_info.gif"/>
      <h:outputText value="Information" style="color: blue; font-size: 16px;"/>
   </h:panelGrid>

   <h:panelGrid columns="2" rendered="#{facesContext.maximumSeverity.ordinal == 2}">
      <h:graphicImage value="/images/icons/mini_error.gif"/>
      <h:outputText value="Error" style="color: red; font-size: 16px;"/>
   </h:panelGrid>

   <!-- f:facet to change messsages markers -->
   <rich:messages id="mpMessage1">
      <f:facet name="infoMarker">
         <h:outputText value="- "/>
      </f:facet>

      <f:facet  name="errorMarker">
         <h:outputText value="- "/>
      </f:facet>
   </rich:messages>
</rich:modalPanel>



</f:subview>
